import java.time.DayOfWeek;
import java.time.LocalDate;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
//        while (true) {
            // test1();
            //  test2();
            test3();
//        }
    }


    public static void test3() {
        System.out.println("请输入日期：");
        Scanner sc = new Scanner(System.in);
        String input = sc.next();
        LocalDate date = LocalDate.parse(input);
        date = date.withDayOfMonth(1);
        System.out.println("一\t二\t三\t四\t五\t六\t日");
        for (int i = 0; i < date.getDayOfWeek().getValue() - 1; i++) {
            System.out.print("\t");
        }
        for (int i = 1; i <= date.lengthOfMonth(); i++) {
            System.out.print(i + "\t");
            if (date.withDayOfMonth(i).getDayOfWeek()==DayOfWeek.SUNDAY) {
                System.out.println();
            }
        }
    }

    private static void test2() {
        int[][] calendar = new int[5][7];
        System.out.println("请输入日期：");
        Scanner sc = new Scanner(System.in);
        String input = sc.next();
        LocalDate date = LocalDate.parse(input);
        DayOfWeek dayOfWeek = date.withDayOfMonth(1).getDayOfWeek();
        int i1 = dayOfWeek.getValue() - 1;
        int day = 1;
        for (int i = 0; i < calendar.length; i++) {
            for (int j = 0; j < calendar[i].length; j++) {
                if (i == 0) {
                    j = i1;
                    calendar[0][j] = day;
                    i1++;
                    day++;
                } else {
                    calendar[i][j] = day;
                    day++;
                }
            }
        }
        System.out.println("一\t二\t三\t四\t五\t六\t日");
        for (int[] ints : calendar) {
            for (int anInt : ints) {
                if (anInt != 0) {
                    System.out.printf("%d\t", anInt);
                } else {
                    System.out.print("\t");
                }
            }
            System.out.println();
        }
    }

    private static void test1() {
        Scanner sc = new Scanner(System.in);
        LocalDate product = null;
        try {
            System.out.println("请输入生产日期：");
            String input = sc.next();
            product = LocalDate.parse(input);
        } catch (Exception e) {
            System.out.println("日期格式错误");
            return;
        }
        System.out.println("请输入保质期(天)：");
        int day = sc.nextInt();

        LocalDate overdue = product.plusDays(day);
        LocalDate with = overdue.minusWeeks(2).with(DayOfWeek.WEDNESDAY);
        System.out.println("促销日 = " + with);
    }
}
